﻿#include "pch.h"
#include "CppUnitTest.h"
#include "../Project1/test.h"
#include "read.h"
#include "judge.h"
#define MAX_LINE 1024  
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest1
{
	TEST_CLASS(UnitTest1)
	{
	public:
		//template <typename T>
		//void isequ(vector<T> ocol, vector<T> rcol) {
		//	for (int i = 0; i < ocol.size(); i++)
		//	{
		//		Assert::AreEqual<T>(ocol[i], rcol[i]);
		//	}
		//}
		//template <typename T>
		//void fuzhi(vector<T>& ocol, vector<T>& rcol, vector<vector<any>> output, vector<vector<any>> result, int col) {
		//	for (int i = 0; i < output.size(); i++) {
		//		ocol.push_back(*output[i][col]._Cast<T>());
		//		rcol.push_back(*result[i][col]._Cast<T>());
		//	}
		//}

		//void isvecequ(vector<vector<any>> output, vector<vector<any>> result, vector<string> outputtype) {
		//	Assert::IsTrue(output.size() == result.size());
		//	Assert::IsTrue(output[0].size() == result[0].size());
		//	for (int j = 0; j < output[0].size(); j++) {
		//		if (outputtype[j] == "int") {
		//			vector<int> ocol, rcol;
		//			fuzhi(ocol, rcol, output, result, j);
		//			isequ(ocol, rcol);
		//		}
		//		if (outputtype[j] == "long") {
		//			vector<long> ocol, rcol;
		//			fuzhi(ocol, rcol, output, result, j);
		//			isequ(ocol, rcol);
		//		}
		//		if (outputtype[j] == "float") {
		//			vector<float> ocol, rcol;
		//			fuzhi(ocol, rcol, output, result, j);
		//			isequ(ocol, rcol);
		//		}
		//		if (outputtype[j] == "double") {
		//			vector<double> ocol, rcol;
		//			fuzhi(ocol, rcol, output, result, j);
		//			isequ(ocol, rcol);
		//		}
		//		if (outputtype[j] == "string") {
		//			vector<string> ocol, rcol;
		//			fuzhi(ocol, rcol, output, result, j);
		//			isequ(ocol, rcol);
		//		}
		//	}
		//}
		TEST_METHOD(TestMethod1)
		{
			Cal c;
			judge Judge;
			int n = 0;
			vector<vector<any>> output;
			vector<string> outputtype;
			vector<vector<any>> input = read::readf("..\\单元测试\\unit-testing-\\test2.txt", output, outputtype);
			vector<vector<any>> result;
			for (int i = 0; i < input.size(); i++) {//只需要重写这一部分就可以
				vector<any> anytem;
				anytem.push_back(c.add(*input[i][0]._Cast<int>(), *input[i][1]._Cast<double>(), *input[i][2]._Cast<string>()));
				anytem.push_back(*input[i][2]._Cast<string>());
				result.push_back(anytem);
			}
			//isvecequ(output, result, outputtype);
			Judge.isvecequ(output, result, outputtype);
		}
	};
}
